package com.itheima.demo;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/**
 * @author Zhang_Han
 * @version 1.0
 * @date 2020/7/10 18:57
 */
public class Demo_003 {
    public static void main(String[] args) throws IOException {
        //需求: 将键盘录入的用户名和密码保存到本地实现永久化存储
        //要求：用户名独占一行，密码独占一行
        //创建字符输出流;
        BufferedWriter bw = new BufferedWriter(new FileWriter("demo_IO\\name01.txt"));
        //创建键盘录入对象;
        Scanner sc = new Scanner(System.in);
        int id = 0;
        for (int i = 1; i <= 2; i++) {
            id++;
            System.out.println("------密码管理------");
            System.out.println("请输入用户名:");
            String username = sc.next();
            System.out.println("请输入密码:");
            String password = sc.next();
            bw.write("------密码管理------");
            bw.newLine();
            bw.write("序号:"+id);
            bw.newLine();
            bw.write("姓名:"+username);
            bw.newLine();
            bw.write("密码:"+password);
            bw.newLine();
        }
        bw.close();
    }
}
